package gov.nasa.anml.lifted;

import gov.nasa.anml.PDDL;
import gov.nasa.anml.State;
import gov.nasa.anml.PDDL.Argument;
import gov.nasa.anml.PDDL.FloatExpression;
import gov.nasa.anml.PDDL.Time;
import gov.nasa.anml.utility.SimpleBoolean;
import gov.nasa.anml.utility.SimpleObject;
import gov.nasa.anml.utility.SimpleVoid;

public class ContainsExpression<E extends Expression<?,?>> extends ConstantExpressionImp<SimpleBoolean> {
	public E e;

	public ContainsExpression() {
		super();
		e=null;
	}
	
	public ContainsExpression(E e) {
		super();
		this.e = e;
	}
	
	public TypeCode typeCode() {
		return TypeCode.Boolean;
	}

	public boolean apply(State p, int contextID, State c) {
		if (e.value(p) == ANMLBoolean.True) {
			//if supplied timewindow for application contains all of e
			// i.e., e.getStart() and so forth
			// then return true
			return true;
		}
		return false;
	}

	public SimpleBoolean value(State s) {
		// the correct semantics are to check whether the history of that expression's truth is contained
		// within the surrounding interval.  This class may need to extend IntervalImp in order to know what
		// that surrounding context is supposed to be.
		return e.value(s) == ANMLBoolean.True ? ANMLBoolean.True : ANMLBoolean.False;
		// the details of what the contained expression's history exactly is depends on the subclass.
	}

	// FIXME: implement for real
	public void translateDecl(PDDL pddl, Interval unit) {
		e.translateDecl(pddl,unit);
	}

	public void translateStmt(PDDL pddl, Interval unit, Time part) {
		e.translateStmt(pddl,unit,part);
	}
	
	public PDDL.Expression translateExpr(PDDL pddl,	Interval unit) {
		return e.translateExpr(pddl,unit);
	}

	public PDDL.Argument translateArgument(PDDL pddl, Interval unit) {
		return e.translateArgument(pddl,unit);
	}


}
